package com.itheima.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.mapper.PmsProductFullReductionMapper;
import com.itheima.pojo.db.PmsProductFullReduction;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class PmsProductFullReductionApiImpl implements PmsProductFullReductionApi {
    @Autowired
    private PmsProductFullReductionMapper pmsProductFullReductionMapper;


    @Override
    public void insertList(List<PmsProductFullReduction> list, Long productId) {
        for (PmsProductFullReduction pmsProductFullReduction : list) {
            pmsProductFullReduction.setId(null);
            pmsProductFullReduction.setProductId(productId);
            pmsProductFullReductionMapper.insert(pmsProductFullReduction);
        }
    }

    @Override
    public void deleteById(Long id) {
        pmsProductFullReductionMapper.delete(new LambdaQueryWrapper<PmsProductFullReduction>().eq(PmsProductFullReduction::getProductId, id));
    }

    @Override
    public List<PmsProductFullReduction> selectByPid(Long id) {
        return pmsProductFullReductionMapper.selectList(new LambdaQueryWrapper<PmsProductFullReduction>().eq(PmsProductFullReduction::getProductId, id));
    }
}
